package main

import (
	"github.com/micro/go-micro"
	"github.com/micro/go-micro/registry"
	"github.com/micro/go-plugins/broker/grpc"
	"github.com/micro/go-plugins/registry/consul"
	"goMicro/day05/server/serviceImpl"
	"goMicro/day05/server/services"
)

func main() {
	//注册 consul
	register := consul.NewRegistry(
		registry.Addrs("127.0.0.1:8500"),
	)
	////注册 etcd
	//register := etcdv3.NewRegistry(
	//	registry.Addrs("127.0.0.1:2379"),
	//)
	//consulReg := etcdv3.NewRegistry(
	//	registry.Addrs("192.168.66.132:8500"),
	//)
	grpcBroker := grpc.NewBroker()
	mService := micro.NewService(
		micro.Name("prodService"),
		micro.Address(":8011"),
		micro.Registry(register), // 注册中心
		micro.Broker(grpcBroker),
	)
	mService.Init()
	// 关键 参数二：就是我们写的实现类
	services.RegisterProdServiceHandler(mService.Server(), new(serviceImpl.ProdService))
	mService.Run()
}
